Comments on Wiki Scrapbook Bookmarklet

 

2 Comments.

hmmm, the Scrapbook Bookmarklet doesn't work if you're not an Editor (or Administrator) of the ZhurnalyWiki ... perhaps the code can be modified to use the Append Comment method rather than an Edit Page approach?! — in which case anybody could use it, which might be nice (or might just open another door to spammers, ugh) ... ^z

z0 2012-05-23 10:31 UTC


Please take a look at http://www.oddmuse.org/wiki/Comments_on_Clipping_Bookmarklet dated 2013-08-25. The approach is purely a Javascript-based one and does not require any new modules on server side.

zzzzz 2013-10-05 16:11 UTC


Oddmuse: Comments on Clipping Bookmarklet

I have made some bug fixes and few other improvements to the earlier bookmarklet.

Following options are configurable:

Variable Description Default Value
wikiBase Base URL for the Wiki 'http://example.org/wiki'
scrapPage Pagename for captured text 'Scraps'
autoSubmit If false, pause for edit. Useful if you want to make additional edits on the captured text.false
autocloseTimeout Oddmuse post window will close after this timeout (in milliseconds).5000
wikiTextSpec Syntax of captured text. The %-specifiers will be replaced as follows.'[%U %T]\n\n%H'
%U => URL of Webpage.
%T => Title of Webpage. (Some webpages have no titles. The script handles this case specially)
%H => Highlighted (or Selected) text.

javascript:void((function() {
    var wikiBase = 'http://example.org/wiki';
    var scrapPage = 'Scraps';
    var autoSubmit = false;
    var autocloseTimeout = 5000;
    var stash = new Object;
    stash.U = document.location;
    stash.T = document.title;
    stash.H = window.getSelection();
    var wikiTextSpec = stash.T ? '[%U %T]\n\n%H'
	:  '[%U]\n\n%H';
    var wikiText = wikiTextSpec.replace(/%([UTH])/g, function(m, p) {return (stash[p] || '');});
    var nw = window.open('','','toolbar=0,resizable=1,scrollbars=1,status=1,width=750,height=500');
    var nwd = nw.document;

    nwd.body.innerHTML =
	'<div class="comment">' +
	'  <form method="post" action="http://localhost/cgi-bin/wiki.pl/Public" enctype="multipart/form-data" accept-charset="utf-8" class="comment">' +
	'    <p>' +
	'      <label for="title">Title:</label>' +
	'      <input name="title" id="title">' +
	'      </input>' +
	'      <br/>' +
	'      <textarea name="aftertext" rows="10" cols="78" id="aftertext">' +
	'      </textarea>' +
	'    </p>' +
	'    <p>' +
	'      <span class="username">' +
	'    	<label for="username">Username:</label>' +
	'    	<input name="username" size="20" maxlength="50" id="username" type="text">' +
	'	</input>' +
	'    	</span>' +
	'    	<br/>' +
	'    	<span class="homepage">' +
	'    	  <label for="homepage">Homepage URL:</label>' +
	'    	  <input name="homepage" size="40" maxlength="100" id="homepage" type="text">' +
	'	  </input>' +
	'    	</span>' +
	'    </p>' +
	'    <p>' +
	'      <input name="Save" value="Save" accesskey="s" type="submit">' +
	'      </input>' +
	'      <input name="Preview" value="Preview" accesskey="p" type="submit">' +
	'      </input>' +
	'    </p>' +
	'  </form>' +
	'</div>';

    nwd.getElementById('title').setAttribute('value', scrapPage);
    nwd.getElementById('aftertext').value = wikiText;

    var f = nwd.forms[0];
    f.setAttribute('action', wikiBase);
    f.onsubmit = function () {self.setTimeout(function () {nw.close ();}, autocloseTimeout);};

    if (autoSubmit) {
	f.submit ();
    }

})())

– orgmuse 2013-10-19 19:39 UTC

zzzz_scrapbooking 2015-08-27 10:15 UTC